﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using FeatureModelTool.ConfigGraphic;
using TreeGraphicalControl;
using FeatureModelCore.Configuration;

namespace FeatureModelTool.FileView
{
    /// <summary>
    /// Interaction logic for ConfigTreeViewTab.xaml
    /// </summary>
    public partial class ConfigTreeViewTab : TabItem, IMainTab
    {
        public static ConfigTreeViewItemGenerator Generator;
        public bool Dirty { get { return false; } }
        public ConfigTreeView TreeView { get { return this.ConfigTreeView; } }
        static ConfigTreeViewTab()
        {
            Generator = new ConfigTreeViewItemGenerator(
                TreeItem_ConfigRoot.ConstructTreeItem, TreeItem_ConfigRoot.GenerateContext);
            // register Group Relationship
            ItemRegister nodeRegister = new ItemRegister(typeof(ConfigNode)
                , typeof(TreeItem_ConfigNode)
                , TreeItem_ConfigNode.ConstructTreeItem
                , TreeItem_ConfigNode.GenerateContext);
            Generator.Register(nodeRegister);
        }
        public ConfigTreeViewTab()
        {
            InitializeComponent();
            this.TreeView.BindGenerator(Generator);

            #region Context Menu
            this.ContextMenu = new ContextMenu();

            #endregion
        }

        /// <summary>
        /// close
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void close_EventHandler(object sender, RoutedEventArgs e)
        {
            TabControl tabControl = (TabControl)this.Parent;
            tabControl.Items.Remove(this);
        }

        public void SaveInstance()
        {
        }
    }
}
